package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.Comment;
import com.tedu._04mybatis.pojo.CommentVO1;
import com.tedu._04mybatis.pojo.CommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
//    数据库 增删改 语法不用写别名的
    @Insert("INSERT INTO comment(content,created,user_id,weibo_id) " +
             "VALUES (#{content},#{created},#{userId},#{weiboId}) ")
    int insertComment(Comment comment);

    @Delete("DELETE FROM comment " +
            "WHERE id = #{id}")
    int deleteById(Integer id);

    @Update("update comment " +
            "set content=#{content},created=#{created},weibo_id=#{weiboId},user_id=#{userId} " +
            "where id = #{id} "
    )
    int updateById(Comment comment);

    @Select("SELECT content,user_id userId,weibo_id weiboId " +
            "FROM comment " +
            "where id = #{id}")
    CommentVO1 selectCommentById1(Integer id);

    @Select("SELECT content,user_id userId " +
            "FROM comment " +
             "where weibo_id = #{weiboId}")
    CommentVO2 selectCommentById2(Integer id);

    int dynamicUpdate0(Comment comment);

    int dynamicDelete0(Integer[] ids);

    int dynamicDelete01(List<Integer> ids);


}
